package com.study.pattern.observer;

import java.util.ArrayList;
import java.util.List;

public class MemberManagement {
	
	List<IUpdatable>memberList = new ArrayList<IUpdatable>();
	
	public void registerMember(IUpdatable updatable){
		memberList.add(updatable);
	}
	
	public void removeMember(IUpdatable updatable){
		int index = memberList.indexOf(updatable);
		if(index>-1){
			memberList.remove(index);
		}
	}
	
	public void notifyUpdate(long interval, String msg){
		for(IUpdatable member : memberList){
			member.update(interval, msg);
		}
	}
	
	public void terminateLady(){
		for(IUpdatable member : memberList){
			member.terminate();
		}
	}
}
